using System;
using System.Data;
using Sanelib.DataOperation;
using Sanelib.DataOperation.Attribute;
using Sanelib.DataOperation.Base;

namespace Core.Domain.Model
{
	[EntityName("Lead")]
	public class Lead : AuditedEntity
	{
		public string CompanyName { get; set; }
		public string Email { get; set; }
		public string Phone { get; set; }

		public override void From(IDataReader dataReader)
		{
			base.From(dataReader);
			CompanyName = dataReader.ReadNullSafeString("CompanyName");
			Email = dataReader.ReadNullSafeString("Email");
			Phone = dataReader.ReadNullSafeString("Phone");
		}

		public override void To(System.Data.SqlClient.SqlCommand cmd)
		{
			base.To(cmd);
            cmd.Parameters.Add("@CompanyName", SqlDbType.NVarChar).Value = (object)CompanyName ?? DBNull.Value;
			cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = Email;
            cmd.Parameters.Add("@Phone", SqlDbType.VarChar).Value = (object)Phone ?? DBNull.Value;
		}
	}
}
